# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from scipy.stats import t

def perform_autocorrelation_test(r, n):
    t_alpha = t.ppf(0.05/2, n-2)
    r_criteria = t_alpha/np.sqrt(n-2+t_alpha**2)
    if abs(r) <= r_criteria:
        return 0
    else:
        return r
